﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using Proggy.Web.Cms.PropertyTypes;
using System.Web.Mvc.Html;

namespace Proggy.Web.Cms.Core.HtmlExtensions
{
    /// <summary>
    /// Auto rendering
    /// </summary>
    public static class AutoRenderExtensions
    {
        /// <summary>
        /// Auto-render from a property type (property type must implement IAutoRenderPropertyType)
        /// </summary>
        /// <param name="html"></param>
        /// <param name="propertyData"></param>
        public static void AutoRenderPropertyTypePartial(this HtmlHelper html, IAutoRenderPropertyType propertyData) {
            try { RenderPartialExtensions.RenderPartial(html, propertyData.FullPathToAutoRenderPartial, propertyData.GetAutoRenderModel()); }
            catch { }
        }
    }
}
